package com.quasar.hpatient.view.personal.setup;

import com.quasar.hpatient.R;
import com.quasar.hpatient.base.BaseActivity;
import com.quasar.hpatient.model.httpmodel.DataHeadResult;
import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.medicalmodel.PatientInfoData;
import com.quasar.hpatient.onInterface.OnEditUserListener;
import com.quasar.hpatient.presenter.PostEditUserPresenter;
import com.quasar.hpatient.widget.EditWidget;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

/**
 * 同共体患者
 */
@EActivity(R.layout.activity_with_donor)
public class WithDonorActivity extends BaseActivity implements OnEditUserListener {

    private PostEditUserPresenter postEditUserPresenter;

    @ViewById(R.id.et_phone)
    EditWidget et_phone;

    @AfterViews
    void init(){
        initView();
        initData();
    }


    @Override
    protected void initView() {
        initToolbar();
    }

    @Override
    protected void initData() {
        postEditUserPresenter=new PostEditUserPresenter(this);
    }

    @Click(R.id.submit)
    public void submit(){
        String phone=et_phone.getText().toString().trim();
        showDialog();
        postEditUserPresenter.SelectTheTotalBodyData(phone);
    }

    @Override
    public void onSuccess(DataStateResult data) {

    }

    @Override
    public void onError(String msg) {
        dessDialog();
        if(msg!=null){
            msg(msg);
        }
    }

    @Override
    public void onRefreshUI() {
        dessDialog();
    }

    @Override
    public void onWithDonorSuccess(DataStateResult data) {
        if(data.getMsgCode().equals("0x00000000")){
            msg("提交成功");
            finish();
        }
        dessDialog();
    }

    @Override
    public void onWithObtain(DataHeadResult<PatientInfoData> dataDataHeadResult) {

    }
}
